#ifndef CHATDIALOG_H
#define CHATDIALOG_H

#include <QWidget>
#include <QTcpSocket>
#include <QMessageBox>
#include <QTimer>
#include <QCloseEvent>
#include <home.h>
#include "control.h"
#include <QLineEdit>

namespace Ui {
class chatdialog;
}

class chatdialog : public QWidget
{
    Q_OBJECT

public:
    explicit chatdialog(QWidget *parent = nullptr);

    chatdialog(int id, QString name);

    ~chatdialog();
    QTimer *timer;
private slots:
    void on_pushButton_clicked();
    void getchathistory();
    void on_pushButton_send_clicked();

    void getnewmessage();

    void on_pushButton_ago_clicked();

    void on_pushButton_backnow_clicked();

protected:
    void closeEvent(QCloseEvent *event);
private:
    Ui::chatdialog *ui;
    QTcpSocket *tcpSocket;
    int oid;
    QString oname;
    int totalCnt = 0;
    home* ho;
    bool nohaveMess = false;
};

#endif // CHATDIALOG_H
